﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;

namespace AgileToDo.Common
{
    [ValueConversion(typeof(DateTime?), typeof(TextDecorationCollection))]
    public class DateTime2TextDecorationsConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {

            var dateTime = (DateTime?) value;

            if (dateTime.HasValue)
                return TextDecorations.Strikethrough;
            else
            {
                return null;
            }

        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {

            var textDec = (TextDecorationCollection)value;

            if (textDec == TextDecorations.Strikethrough)
                return DateTime.Now;

            if (textDec == null)
                return null;

            return null;

        }

    }
}
